<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>第一节课</title>
		<style type="text/css">
			/*去除原来样式*/
			
			* {
				padding: 0;
				margin: 0;
			}
			
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				/*
				 * 将边框设置在中间
				 */
				align-items: center;
				justify-content: center;
			}
			
			canvas {
				width: 500px;
				height: 500px;
				border: 1px solid #333333;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>

	<script>
		
		window.onload = function() {
			//let oCanvas = document.getElementById('canvas');
			let oCanvas = document.getElementById("canvas");
			let pen = oCanvas.getContext("2d");

			//createLinearGradient(x1,y1,x2,y2)
			//addColorStop(value1,color1);
			//addColorStop(value2,color2);
			
			//从左上角到右下角
			//var gradual = pen.createLinearGradient(500,500,0,0);
			
			//从右上角到左下角
			//var gradual = pen.createLinearGradient(500,0,0,500);
			
			//从左到右
			//var gradual = pen.createLinearGradient(0,0,500,0);
			
			//从上到下
			//var gradual = pen.createLinearGradient(0,0,0,500);
			
			//填充
			/*gradual.addColorStop(0.5,"red");
			gradual.addColorStop(0.25,"blue");
			gradual.addColorStop(0.5,"green");
			gradual.addColorStop(0.75,"yellow");*/
			//pen.fillStyle = gradual;
			//pen.fillRect(0,0,500,500);
			
			//文字渐变
			/*pen.font = "100px bold";
			pen.fillText("Hello ",80,250);
			pen.fillText("World!",180,300);*/
			
			
			
			
			
			//圆形渐变
			
			//开始渐变点的坐标，半径，渐变结束时圆心的坐标，结束时半径
			/*var obj = pen.createRadialGradient(100,60,10,80,80,50);
			obj.addColorStop(0,"white");
			obj.addColorStop(0.9,"orange");
			obj.addColorStop(1,"rgb(0,0,0,0)");
			pen.fillStyle = obj;
			pen.arc(80,80,50,0,Math.PI/180*360,true);
			pen.fill();*/
			
			/*var obj = pen.createRadialGradient(250,250,200,250,250,50);
			obj.addColorStop(0,"white");
			obj.addColorStop(0.5,"orange");
			pen.fillStyle = obj;
			pen.arc(250,250,200,0,Math.PI/180*360,true);
			pen.fill();*/
			
			
			/*var obj = pen.createRadialGradient(250,250,200,100,100,300);
			obj.addColorStop(1,"white");
			obj.addColorStop(0.5,"orange");
			obj.addColorStop(1,"rgb(0,0,0,0)");
			pen.fillStyle = obj;
			pen.arc(250,250,200,0,Math.PI/180*360,true);
			pen.fill();*/
			
			
			//偏移方向 x轴方向/y轴方向（值为0时向四周偏移）
			//shadowOffsetX/shadowOffsetY
			//阴影的颜色
			//shadowColor
			//模糊程度，越大越模糊
			//shadowBlur
			
			//实例
			pen.shadowBlur=100;
			pen.shadowOffsetX=0;
			pen.shadowOffsetY=0;
			pen.shadowColor = "orange";
			
			pen.fillStyle = "orange";
			//pen.fillRect(100,100,100,100);
			pen.arc(250,250,200,0,Math.PI/180*360,true);
			pen.fill();
		}
	</script>

</html>